package com.yoda.mall.admin.service;

import cn.hutool.core.convert.Convert;
import com.yoda.mall.api.ResourceCategoryApi;
import com.yoda.mall.model.entity.ums.ResourceCategory;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ResourceCategoryService {
    @DubboReference
    private ResourceCategoryApi resourceCategoryApi;

    public List<ResourceCategory> listAll() {
        return resourceCategoryApi.list();
    }

    public void create(ResourceCategory resourceCategory) {
        resourceCategoryApi.create(resourceCategory);
    }

    public void delete(Integer id) {
        resourceCategoryApi.deleteById(id);
    }

    public void update(Integer id, ResourceCategory resourceCategory) {
        resourceCategory.setId(Convert.toLong(id));
        resourceCategoryApi.updateById(resourceCategory);

    }
}
